   package com.javalong.affairs.base.viewpagerfragment;

import android.R;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.view.View;

public class ViewPagerTitleBar extends View {
	// 榛樿搴曢儴绾跨殑楂桦害
	private final static int DEFAULT_LINE_HEIGHT = 10;
	// 榛樿涓?0,绾跨殑瀹藉害涓烘枃瀛楃殑瀹藉害锛屼笉涓?0,鍒椤悜宸﹀彸寤朵几
	private final static int DEFAULT_LINE_ADD = 0;
	// 榛樿搴曢儴绾挎浔棰滆壊
	private final static int DEFAULT_LINE_COLOR = R.color.holo_orange_light;
	// 绾挎浔镄勫
	private int width = 100;
	// 绾挎浔璺濆乏杈圭殑璺濈
	private int left = 100;
	private Paint p;

	public void setLocation(int width, int left) {
		this.width = width;
		this.left = left;
	}

	public ViewPagerTitleBar(Context context) {
		super(context);
		init();
	}

	private void init() {
		p = new Paint();
		p.setStyle(Style.FILL);
		p.setColor(getResources().getColor(DEFAULT_LINE_COLOR));
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		canvas.drawRect(left - DEFAULT_LINE_ADD, 0, left + width
				+ DEFAULT_LINE_ADD, DEFAULT_LINE_HEIGHT, p);
	}

}
